package net.wing.demo.dao.row;

import com.alibaba.fastjson.JSONObject;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Author beifengtz
 * @Date Created in 9:02 2018/8/10
 * @Description:    对查询结果进行封装，此处并未封装成实体，而是封装成json对象
 */
public class MessageRow implements RowMapper {
    @Override
    public Object mapRow(ResultSet resultSet, int i) throws SQLException {
        if(i>=0){
            JSONObject tempJson = new JSONObject();
            tempJson.put("id",resultSet.getInt("id"));
            tempJson.put("content",resultSet.getString("message_content"));
            tempJson.put("date",resultSet.getInt("message_date"));
            return tempJson;
        }else{
            return null;
        }
    }
}
